<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/page/share/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加商场用户</title>
<script type="text/javascript" language="javascript">
	function refreshcode(){
		   document.getElementById("code").src="<html:rewrite action="/validate/manage"/>?method=build&a="+Math.random()+100;
		   return false;
	}
	function validate(){
		var form = document.forms[0];
		if(form.username.value=="" || form.username.value.length<6){
			alert("请输入长度6位以上的用户名");
			return false;
		}
		if(/[\W]/g.test(form.username.value)){
			alert("用户名中不能含有中文");
			return false;
		};
		if(form.password.value=="" || form.password.value.length<6){
			alert("请输入长度6位以上的密码");
			return false;
		}
		if(form.password.value!=form.passwordagain.value){
			alert("两次输入的密码不正确");
			return false;
		}
		
		if(form.name.value==""){
			alert("商场名称不能为空!");
			return false;
		}
		var imagefile = document.getElementById("imageFile");
		alert("the imagefile.value is:"+imagefile.value);
		if(imagefile.value==""){
			alert("商场的logo不能为空!");
			return false;
		}
		if(form.address.value==""){
			alert("商场的联系地址不能为空!");
			return false;
		}
		
		if(form.parentId.value == ""){
			alert("商场所属地区不能空!");
			return false;
		}
		if(form.email.value == ""){
			alert("联系邮箱不能为空!");
			return false;
		}
		if(form.validatecode.value==null || form.validatecode.value==""){
			alert("验证码不能为空!");
			return false;
		}
	}
</script>
</head>
<body>

	<html:form action="/market/manage" method="post" enctype="multipart/form-data" onsubmit="javascript:return validate()">
	<html:hidden property="parentId" value="${requestScope.belongToaddress.addressId}"/>
	<c:if test="${empty requestScope.market}">
		<input type="hidden" name="method" value="reg" />
	</c:if>
	<c:if test="${!empty requestScope.market}">
		<input type="hidden" name="method" value="edit" />
	</c:if>
		 <c:if test="${empty requestScope.market}">
			 <center>用户名：<html:text property="username"/><font color="red">*</font><font color="red">${requestScope.username_null }${requestScope.username_exist }</font></center>
			 <center>密码:<html:password property="password" /><font color="red">*</font><font color="red">${requestScope.password_null }</font></center>
			 <center>重复密码:<input type="password" name="passwordagain" /><font color="red">*</font></center>
		 </c:if>
		 <center>商场名字:<html:text property="name" /><font color="red">*</font> <font color="red">${requestScope.name_null }</font></center>
		 
		 <center>商场Logo:<input type= "file" name="imageFile" id="imageFile" size="30" /></center>
		 <c:if test="${!empty requestScope.market.imageName}">
		 	<center><html:img src="/shop/${requestScope.market.image140FullPath}" alt="${requestScope.market.name}"/></center>
		 </c:if>
		 <center>联系地址:<html:text property="address" /><font color="red">*</font><font color="red">${requestScope.address_null }</font></center>
		 <center>所属地区:<input type="text" name="parent" readonly="readonly" /><input type="button" value="选择..." onClick="window.open('<html:rewrite action="/address/manage"/>?method=selectUI','列表','height=600,width=400,scrollbars=yes,status =yes')"/></center>
		 <center>电话:<html:text property="phone" /></center>
		 <center>邮箱:<html:text property="email" /><font color="red">*</font><font color="red">${requestScope.email_null }</font></center>
		 <center>传真:<html:text property="foxmail" /></center>
		 <center>备注:<html:textarea property="remark" rows="20" cols="30"></html:textarea></center><br/>
		 <center><input type="text" name="validatecode"></input><img id="code" src='<html:rewrite action="/validate/manage"/>?method=build' title="看不清点击刷新验证码" style="cursor : pointer;"  onclick="return refreshcode()"/><div><font color="red">${validatecode_null }</font></div></center>
		 <c:if test="${!empty requestScope.market}">
		 	<center><input type="submit" value="修改"></input></center>
		 </c:if>
		 <c:if test="${empty requestScope.market}">
		 	<center><input type="submit" value="提交"></input></center>
		 </c:if>
	</html:form>
</body>
</html>